<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.keywords" placeholder="开通编号、玩家名称、玩家账号" clearable style="width: 240px"></el-input>
      </el-form-item>
      <el-form-item label="起始时间">
		<el-date-picker
          v-model="dataForm.startTime"
          type="datetime"
          value-format = "yyyy-MM-dd HH:mm:ss"
          placeholder="起始时间">
		</el-date-picker>
	  </el-form-item>
	  <el-form-item label="结束时间">
		<el-date-picker
          v-model="dataForm.endTime"
          type="datetime"
          value-format = "yyyy-MM-dd HH:mm:ss"
          placeholder="结束时间">
		</el-date-picker>
	  </el-form-item>
      <el-form-item label="券类型">
		<el-select v-model="dataForm.playState" placeholder="券玩家状态类型">
		  <el-option label="全部" value="" ></el-option>
		  <el-option label="过期" value="0" ></el-option>
          <el-option label="正在使用" value="1" ></el-option>
		</el-select>
	  </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <!-- <el-button v-if="isAuth('goods:shoppinggoods:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
        <el-button v-if="isAuth('goods:shoppinggoods:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> -->
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <!-- <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column> -->
      <el-table-column
        prop="playerNo"
        header-align="center"
        align="center"
        label="开通编号"
        width="200px">
      </el-table-column>
      <el-table-column
        prop="payTrueName"
        header-align="center"
        align="center"
        label="玩家名称"
        width="155px">
      </el-table-column>
      <el-table-column
        prop="payName"
        header-align="center"
        align="center"
        label="玩家账号"
        width="160px">
      </el-table-column>
      <el-table-column
        prop="payUserType"
        header-align="center"
        align="center"
        label="玩家类型"
        width="200px">
      </el-table-column>
      <el-table-column
        prop="createTime"
        header-align="center"
        align="center"
        label="首次开通时间"
        width="155px">
      </el-table-column>
      <el-table-column
        prop="playerCount"
        header-align="center"
        align="center"
        label="当月剩余次数">
      </el-table-column>
      <el-table-column
        prop="playerMoney"
        header-align="center"
        align="center"
        label="支付金额">
        <template slot-scope="scope">
          <span v-if="scope.row.playerMoney != null">￥ {{scope.row.playerMoney}}</span>
          <span v-if="scope.row.playerMoney == null">￥ 0</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="tradeNo"
        header-align="center"
        align="center"
        label="流水号"
        width="240px">
      </el-table-column>
      <el-table-column
        prop="state"
        header-align="center"
        align="center"
        label="当前状态">
      </el-table-column>
      <el-table-column
        prop="startTime"
        header-align="center"
        align="center"
        label="开始时间"
        width="155px">
      </el-table-column>
      <el-table-column
        prop="endTime"
        header-align="center"
        align="center"
        label="结束时间"
        width="155px">
      </el-table-column>
      <el-table-column
        prop="playerSrc"
        header-align="center"
        align="center"
        label="来源">
      </el-table-column>
      <el-table-column
        prop="payFrom"
        header-align="center"
        align="center"
        label="支付方式">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        dataForm: {
          keywords: '',
          startTime: '',
          endTime: '',
          logsType: '',
          goodsType: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/coupon/queryOpeningRecordList'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'keywords': this.dataForm.keywords,
            'startTime': this.dataForm.startTime,
            'endTime': this.dataForm.endTime,
            'playState': this.dataForm.playState
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.data.list
            this.totalPage = data.data.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      }
    }
  }
</script>
